package org.lysh.exception;

import org.lysh.enums.BusinessCode;

import java.io.Serializable;

/**
 * @author liyishan
 * @date 2024/4/24 15:36
 * @apiNote
 */

public class BusinessException extends RuntimeException implements Serializable {
    private String code;
    private String msg;

    public BusinessException(String code, String msg) {
        super(msg);
        this.code = code;
        this.msg = msg;
    }

    public BusinessException(String msg) {
        super(msg);
        this.code = BusinessCode.FATAL.getCode();
        this.msg = msg;
    }

    public BusinessException(BusinessCode error) {
        super(error.getDesc());
        this.code = error.getCode();
        this.msg = error.getDesc();
    }

    public String getCode() {
        return this.code;
    }

    public String getMsg() {
        return this.msg;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }
}
